//chainmine.txt - Part of a chain of mines. It just sits there and can be disarmed.
//  It goes off when a trigmine object sends it message 105. 
//Cell 0 - Difficulty of trap ... the total tool use needed to disarm.
//Cell 1 - The effect created.
//  0 - fiery boom (1-6 dam/level)
//  1 - magical boom (1-8 dam/level)
//  2 - spray acid (1-2 pts/level)
//  3 - spray poison (1-2 pts/level)
//  4 - spawn creature (damage is spawn #, not in game #)
//  5 - debuff shield/bless
//  6 - debuff slow
//Cell 2 - The damage of the trap. Should be roughly equal to the level of 
//  the character you want to kill with it. Defaults to 6.
//  If the mine spawns a creature, this is the town roster of the creature (not in game #).

beginobjectscript; 

variables;
short disarmed = 0;
short exploded = 0;
short near_char;
short r1;
short cur_tick;

body;

beginstate INIT_STATE;
		cur_tick = get_current_tick();
	break;

beginstate DEAD_STATE;

break;

beginstate START_STATE; // door closed, waiting
	if ((char_ok(45)) && (get_attitude(45) < 10)) {
		if ((gf(60,9) > 5) && (num_chars_in_group(5) > 0) && (cur_tick != get_current_tick())) {
			cur_tick = get_current_tick();

			run_sparkles_on_object(ME,162,1,4);
	  		create_missile_spiral(155,20,8,2);
			damage_nearby(get_ran(1,300,400),8,1,1);
		
			print_str_color("The spiral sends out a wave of static.",2);
			}
		end();
		}

	if ((char_ok(45)) && (get_attitude(45) >= 10)) {
		if ((get_nearest_party_char(8) >= 0) && (cur_tick != get_current_tick()) && (get_memory_cell(0) == 0)) {
			cur_tick = get_current_tick();

			if (get_ran(1,0,1) == 0) {
				run_sparkles_on_object(ME,162,1,4);
				create_missile_spiral(155,20,7,2);
				damage_nearby(get_ran(1,300,400),7,1,0);
			
				print_str_color("A spiral sends out a wave of searing heat.",2);
				}
			}
		if ((get_nearest_party_char(8) >= 0) && (cur_tick != get_current_tick()) && (get_memory_cell(0) != 0)) {
			cur_tick = get_current_tick();

			if (get_ran(1,0,1) == 0) {
				run_sparkles_on_object(ME,4,9,1);
				spray_missiles(37,8,8);
				damage_nearby(get_ran(1,300,400),7,1,0);
				status_nearby(60,8,5,0);
			
				print_str_color("A spiral sends out a shower of disorienting sparkles.",2);
				}
			}
		end();
		}
		

break;

beginstate USE_STATE;
	print_str_color("You try to tinker with the pylon. It doesn't have any sort of controls or",2);
	print_str_color("  access panel. You decide to leave it alone. Otherwise, you'll probably",2);
	print_str_color("  cause an explosion.",2);

break;